package com.good.msgsys.service.impl;

import com.good.msgsys.dao.AwardDao;
import com.good.msgsys.dto.PageResult;
import com.good.msgsys.entity.response.AwardVo;
import com.good.msgsys.service.AwardService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;

/**
 * @author junlong
 * @date 2021/1/7 17:32
 */
@Service
public class AwardServiceImpl implements AwardService {
    @Autowired
    private AwardDao awardDao;

    @Override
    public PageResult<AwardVo> findAll(Integer page, Integer limit) {
        Pageable pageable = PageRequest.of(page, limit);
        Page<AwardVo> awardVoPage = awardDao.findAllAward(pageable);
        return new PageResult<>(awardVoPage.getTotalElements(), awardVoPage.getContent(), (long) awardVoPage.getTotalPages());
    }
}
